package org.gangcai.mac.shop.api;

import org.gangcai.mac.shop.bean.AddressBean;
import org.gangcai.mac.shop.bean.BillBean;
import org.gangcai.mac.shop.bean.BrandBean;
import org.gangcai.mac.shop.bean.CartsBean;
import org.gangcai.mac.shop.bean.CateGoodsBean;
import org.gangcai.mac.shop.bean.CategoryBean;
import org.gangcai.mac.shop.bean.CommonResonseBean;
import org.gangcai.mac.shop.bean.ConfirmOrderBean;
import org.gangcai.mac.shop.bean.DynamicBean;
import org.gangcai.mac.shop.bean.EveryDayBean;
import org.gangcai.mac.shop.bean.ExtentionBean;
import org.gangcai.mac.shop.bean.FenqiBean;
import org.gangcai.mac.shop.bean.FenqiBean2;
import org.gangcai.mac.shop.bean.GetPartMoneyBean;
import org.gangcai.mac.shop.bean.GoodDescBean;
import org.gangcai.mac.shop.bean.GoodInfoDetail;
import org.gangcai.mac.shop.bean.GoodInfoBean;
import org.gangcai.mac.shop.bean.HelpBean;
import org.gangcai.mac.shop.bean.HomeDataBean;
import org.gangcai.mac.shop.bean.HomeDataUserBean;
import org.gangcai.mac.shop.bean.HomeIndexBean;
import org.gangcai.mac.shop.bean.HomeMainDataBean;
import org.gangcai.mac.shop.bean.IndexBean;
import org.gangcai.mac.shop.bean.MyInviteBean;
import org.gangcai.mac.shop.bean.OrderBean;
import org.gangcai.mac.shop.bean.OrderDetailBean;
import org.gangcai.mac.shop.bean.PersonCenterBean;
import org.gangcai.mac.shop.bean.PullAuthoBean;
import org.gangcai.mac.shop.bean.QiniuBean;
import org.gangcai.mac.shop.bean.QuotaBean;
import org.gangcai.mac.shop.bean.ReBean;
import org.gangcai.mac.shop.bean.ReSaleBean;
import org.gangcai.mac.shop.bean.RecommendBean;
import org.gangcai.mac.shop.bean.SlideBean;
import org.gangcai.mac.shop.bean.UserDataBean;
import org.gangcai.mac.shop.bean.UserInfoBean;
import org.gangcai.mac.shop.bean.UserMessageBean;
import org.gangcai.mac.shop.bean.WithDrawBean;


import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * Created by mac on 2018/4/4.
 */

public interface AppAPI {
    /**
     * 登录
     *
     * @param mobile
     * @param pwd
     * @return
     */
    @FormUrlEncoded
    @POST("login")
    Observable<CommonResonseBean> login(@Field("mobile") String mobile, @Field("pwd") String pwd);

    @GET("ECMobile")
    Observable<UserInfoBean> signin(@Query("url") String path, @Query("name") String mobile, @Query("password") String pwd);


    /**
     * 发送验证码
     * type  0 注册
     * 1忘记密码
     *
     * @return
     */
    @GET("send_code")
    Observable<CommonResonseBean> sendCode(@Query("mobile") String mobile, @Query("type") String type);


    @FormUrlEncoded
    @POST("forget_pwd")
    Observable<CommonResonseBean> forget_pwd(@Field("mobile") String mobile, @Field("code") String code, @Field("new_pwd") String new_pwd, @Field("renew_pwd") String renew_pwd);

    @FormUrlEncoded
    @POST("register")
    Observable<CommonResonseBean> register(@Field("mobile") String mobile, @Field("code") String code, @Field("invite_code") String invite_code, @Field("pwd") String pwd, @Field("re_pwd") String re_pwd);

    @GET("index")
    Observable<IndexBean> index(@Query("uid") String uid);

    @GET("ECMobile")
    Observable<HomeIndexBean> homedata(@Query("url") String path);

    @GET("ECMobile")
    Observable<BrandBean> brand(@Query("url") String path);

    @GET("ECMobile")
    Observable<CategoryBean> category(@Query("url") String path);

    @GET("ECMobile")
    Observable<DynamicBean> dynamic(@Query("url") String path, @Query("last") String last);

    @GET("ECMobile")
    Observable<CateGoodsBean> goodslist(@Query("url") String path, @Query("cat_id") String cat_id, @Query("order") String order);

    @GET("ECMobile")
    Observable<CateGoodsBean> search_intro(@Query("url") String path, @Query("intro") String intro, @Query("order") String order);

    @GET("ECMobile")
    Observable<RecommendBean> recommend(@Query("url") String path, @Query("last") String last);

    @GET("index.php")
    Observable<SlideBean> Slide(@Query("g") String group,@Query("m") String model,@Query("a") String action,@Query("cid") String cid);

    @GET("index.php")
    Observable<HomeDataBean> HomeData(@Query("g") String group, @Query("m") String model, @Query("a") String action, @Query("cid") String cid);

    @GET("index.php")
    Observable<HomeDataUserBean> HomePersonalData(@Query("g") String group, @Query("m") String model, @Query("a") String action, @Query("cid") String cid, @Query("userid") String userid);

    @GET("index.php")
    Observable<HomeDataBean> ReplayData(@Query("g") String group, @Query("m") String model, @Query("a") String action);

    @GET("index.php")
    Observable<HomeMainDataBean> HomeMainData(@Query("g") String group, @Query("m") String model, @Query("a") String action);

    @GET("index.php")
    Observable<QiniuBean> getQiniuToken(@Query("g") String group, @Query("m") String model, @Query("a") String action);

    @FormUrlEncoded
    @POST("index.php?g=user&m=login&a=dologinjson")
    Observable<UserDataBean> LoginData(@Field("username") String username, @Field("password") String password);

    @FormUrlEncoded
    @POST("index.php?g=user&m=index&a=do_avatar_json")
    Observable<CommonResonseBean> UpdaateNickName(@Field("userid") String username, @Field("user_nicename") String nicename, @Field("imgurl") String imgurl);

    @FormUrlEncoded
    @POST("index.php?g=portal&m=article&a=add_post_json")
    Observable<CommonResonseBean> AddPostArticle(@Field("userID") String username, @Field("term") String termId, @Field("post[post_title]") String post_title, @Field("photos_url[]") String[] photos_url, @Field("post[post_price]") String post_price, @Field("post[post_region]") String post_region,@Field("post[post_area]") String post_area, @Field("post[post_excerpt]") String post_content);

    @FormUrlEncoded
    @POST("index.php?g=portal&m=article&a=post_comment_json")
    Observable<CommonResonseBean> PostArticleComment(@Field("uid") String uid, @Field("post_id") String post_id, @Field("full_name") String full_name, @Field("content") String content);

    @FormUrlEncoded
    @POST("index.php?g=user&m=register&a=doregisterjson")
    Observable<UserDataBean> RegisterData(@Field("mobile") String mobile, @Field("password") String password, @Field("mobile_verify") String mobile_verify);

    @FormUrlEncoded
    @POST("index.php?g=user&m=login&a=dopassword_reset_json")
    Observable<UserDataBean> FindPasswordData(@Field("mobile") String mobile, @Field("password") String password, @Field("mobile_verify") String mobile_verify);

    @FormUrlEncoded
    @POST("index.php?g=user&m=public&a=do_favorite_json")
    Observable<CommonResonseBean> DoFavorite(@Field("uid") String uid, @Field("title") String title, @Field("table") String table, @Field("object_id") String id);

    @FormUrlEncoded
    @POST("index.php?g=user&m=public&a=do_hits_json")
    Observable<CommonResonseBean> DoHits(@Field("userid") String userid, @Field("title") String title, @Field("table") String table, @Field("object_id") String id);

    @FormUrlEncoded
    @POST("index.php?g=user&m=register&a=doregisterPhoneSendCode")
    Observable<UserMessageBean> SendCode(@Field("mobile") String mobile);

    @GET("ECMobile")
    Observable<CartsBean> carts_list(@Query("m") String path, @Query("user_id") String user_id);

    @GET("ECMobile")
    Observable<CommonResonseBean> carts_create(@Query("url") String path, @Query("user_id") String user_id, @Query("goods_id") String goods_id, @Query("number") String number);

    @GET("goods_info")
    Observable<GoodInfoDetail> goods_info(@Query("id") String id);

    @GET("ECMobile")
    Observable<GoodInfoBean> goods_infos(@Query("url") String path, @Query("id") String goods_id, @Query("user_id") String user_id);

    @GET("ECMobile")
    Observable<GoodDescBean> goods_info_desc(@Query("url") String path, @Query("id") String goods_id, @Query("action") String action);

    @FormUrlEncoded
    @POST("add_address")
    Observable<CommonResonseBean> add_address(@Field("uid") String uid, @Field("name") String name, @Field("mobile") String mobile, @Field("city") String city, @Field("address") String address);


    @GET("address_list")
    Observable<AddressBean> address_list(@Query("uid") String uid);

    @GET("address_del")
    Observable<CommonResonseBean> address_del(@Query("id") String id);

    /**
     * 商品转卖
     *
     * @param uid
     * @param gid
     * @param order_id
     * @param money
     * @return
     */

    @FormUrlEncoded
    @POST("goods_resell")
    Observable<CommonResonseBean> goods_resell(@Field("uid") String uid, @Field("gid") String gid, @Field("order_id") String order_id, @Field("money") String money);


    @GET("goods_resell_info")
    Observable<ReSaleBean> goods_resell_info(@Query("id") String id);


    @GET("personal_center")
    Observable<PersonCenterBean> personal_center(@Query("uid") String uid);

    @FormUrlEncoded
    @POST("add_bankcard")
    Observable<CommonResonseBean> add_bankcard(@Field("uid") String uid, @Field("user_name") String user_name, @Field("bank_name") String bank_name, @Field("bankcard_number") String bankcard_number);

    @GET("bankcard_list")
    Observable<WithDrawBean> bankcard_list(@Query("uid") String uid);

    /**
     * 取现
     *
     * @param uid
     * @param user_name
     * @param bank_name
     * @param bankcard_number
     * @return
     */
    @FormUrlEncoded
    @POST("cash")
    Observable<CommonResonseBean> cash(@Field("uid") String uid, @Field("money") String money, @Field("user_name") String user_name, @Field("bank_name") String bank_name, @Field("bankcard_number") String bankcard_number);

    /**
     * 我的邀请码
     *
     * @param uid
     * @return
     */
    @GET("my_invitecode")
    Observable<MyInviteBean> my_invitecode(@Query("uid") String uid);

    /**
     * 我的二维码
     *
     * @param uid
     * @return
     */
    @GET("my_qrcode")
    Observable<CommonResonseBean> my_qrcode(@Query("uid") String uid);

    /**
     * 我的推广列表
     *
     * @param uid
     * @return
     */
    @GET("my_extension")
    Observable<ExtentionBean> my_extension(@Query("uid") String uid);

    @GET("my_quota")
    Observable<QuotaBean> my_quota(@Query("uid") String uid);

    @GET("confirm_order")
    Observable<ConfirmOrderBean> confirm_order(@Query("uid") String uid, @Query("gid") String gid);

    @GET("stagepay_type")
    Observable<FenqiBean> stagepay_type(@Query("money") String money, @Query("uid") String uid);

    @GET("order_complete")
    Observable<CommonResonseBean> order_complete(@Query("id") String id);


    @GET("my_order")
    Observable<OrderBean> my_order(@Query("uid") String uid, @Query("type") String type);

    @GET("order_info")
    Observable<OrderDetailBean> order_info(@Query("uid") String uid, @Query("order_id") String order_id);

    @GET("my_bill")
    Observable<BillBean> my_bill(@Query("uid") String uid);


    @FormUrlEncoded
    @POST("change_photo")
    Observable<CommonResonseBean> change_photo(@Field("uid") String uid, @Field("photo") String photo);

    @FormUrlEncoded
    @POST("pay_stage")
    Observable<FenqiBean2> pay_stage(@Field("uid") String uid,
                                     @Field("stage") String stage,
                                     @Field("receive_name") String receive_name,
                                     @Field("receive_mobile") String receive_mobile,
                                     @Field("receive_address") String receive_address,
                                     @Field("pay_type") String pay_type,
                                     @Field("gid") String gid, @Field("code") String code);


    @FormUrlEncoded
    @POST("apply_intermediary")
    Observable<CommonResonseBean> apply_intermediary(@Field("uid") String uid, @Field("user_name") String user_name,
                                                     @Field("mobile") String mobile, @Field("qq") String qq,
                                                     @Field("wechat") String wechat, @Field("message") String message);

    //    @POST("realname_ident")
    @POST()
    Observable<CommonResonseBean> realname_ident(@Url String url, @Body RequestBody Body);

    /**
     * 认证统一网络管理
     *
     * @param url
     * @param Body
     * @return
     */
    @POST()
    Observable<CommonResonseBean> authoData(@Url String url, @Body RequestBody Body);


    @FormUrlEncoded
    @POST("operator_ident")
    Observable<CommonResonseBean> operator_ident(@Field("uid") String uid, @Field("operator") String operator,
                                                 @Field("mobile") String mobile, @Field("service_pwd") String service_pwd);


    @FormUrlEncoded
    @POST("contacts_ident")
    Observable<CommonResonseBean> contacts_ident(@Field("uid") String uid,
                                                 @Field("father_name") String father_name,
                                                 @Field("father_mobile") String father_mobile,
                                                 @Field("mother_name") String mother_name,
                                                 @Field("mother_mobile") String mother_mobile,
                                                 @Field("instructor_name") String instructor_name,
                                                 @Field("instructor_mobile") String instructor_mobile,
                                                 @Field("roommate_name") String roommate_name,
                                                 @Field("roommate_mobile") String roommate_mobile,
                                                 @Field("classmate_name") String classmate_name,
                                                 @Field("classmate_mobile") String classmate_mobile);

    @POST("culture_ident")
    Observable<CommonResonseBean> culture_ident(@Body RequestBody Body);

    @FormUrlEncoded
    @POST("taobao_ident")
    Observable<CommonResonseBean> taobao_ident(@Field("uid") String uid,
                                               @Field("address_img") String address_img,
                                               @Field("order_img") String order_img);

    @FormUrlEncoded
    @POST("qq_ident")
    Observable<CommonResonseBean> qq_ident(@Field("uid") String uid,
                                           @Field("qq") String qq,
                                           @Field("openid") String openid);

    @FormUrlEncoded
    @POST("bankcard_ident")
    Observable<CommonResonseBean> bankcard_ident(@Field("uid") String uid,
                                                 @Field("card_number") String card_number);

    /**
     * 调用支付宝支付
     *
     * @param uid
     * @param gid
     * @param receive_name
     * @param receive_mobile
     * @param receive_address
     * @return
     */
    @FormUrlEncoded
    @POST("alipay_buy")
    Observable<ReBean> alipay_buy(@Field("uid") String uid,
                                  @Field("gid") String gid,
                                  @Field("receive_name") String receive_name,
                                  @Field("receive_mobile") String receive_mobile,
                                  @Field("receive_address") String receive_address,
                                  @Field("code") String code
    );


    /**
     * 支付宝还款
     *
     * @param uid
     * @return
     */
    @FormUrlEncoded
    @POST("alipay_repayment")
    Observable<ReBean> alipay_repayment(@Field("uid") String uid,
                                        @Field("type") String type,
                                        @Field("money") String money,
                                        @Field("stage_id") String stage_id);

    @GET("helpcenter_list")
    Observable<HelpBean> helpcenter_list();

    /**
     * 获取分期还款金额
     *
     * @return
     */
    @GET("get_partmoney")
    Observable<GetPartMoneyBean> get_partmoney(@Query("type") String type,
                                               @Query("uid") String uid,
                                               @Query("stage_id") String stage_id);


    @GET()
    Observable<PullAuthoBean> getAuthoData(@Url String url, @Query("uid") String uid);


    @FormUrlEncoded
    @POST("get_contacts")
    Observable<CommonResonseBean> submitUserInfo(@Field("id") String uid,
                                                 @Field("contacts") String contacts);

    @FormUrlEncoded
    @POST("get_location")
    Observable<CommonResonseBean> get_location(@Field("id") String uid,
                                               @Field("date") String date,
                                               @Field("latitude") String latitude,
                                               @Field("longitude") String longitude,
                                               @Field("address") String address);

    @GET("everyday_pay")
    Observable<EveryDayBean> everyDayPay(@Query("stage_id") String stage_id);
}
